using NakedObjects.Boot;
using NakedObjects.Core.Context;
using NakedObjects.Core.NakedObjectsSystem;
using NakedObjects.EntityObjectStore;
using NakedObjects.Web.Mvc;
using NakedObjects.Web.Mvc.Helpers;
using NakedObjects.Services;
using RTC.Modelo.Repository;
using InicializadorModelo;

using FUFDomain.Undo;
using FUFDomain.SystemStatus;
using RTC.Modelo.Entidades.EstudiosPropios;
using RTC.Modelo.Entidades.Convalidaciones;
using RTC.Modelo.Entidades;
using RTC.Modelo.Entidades.DatosPersonales;

namespace MVC.App_Start {
    public class RunWeb : RunMvc {
        protected override NakedObjectsContext Context {
            get { return HttpContextContext.CreateInstance(); }
        }

        protected override IServicesInstaller MenuServices {
            get {
                

                ServicesInstaller si = new ServicesInstaller(new object[] { 
                    new Inicializador(),
                    //new SolicitudRepository(),                    
                    new SimpleRepository<RTC.Modelo.Entidades.Solicitud>()  ,
                    new  CentroEstudiosRepository(),                       
                    new ConvalidacionRepository()  ,
                });

                //InicializadorModelo.Inicializador.Inicializar(rpSol.Container);
                return si;
            }
        }

        protected override IServicesInstaller ContributedActions {
            get { return new ServicesInstaller(new object[] {
                new UndoManager(),
                new SystemStatus()            
            }); }
        }

        protected override IServicesInstaller SystemServices {
            get { return new ServicesInstaller(new object[] {
                new SimpleEncryptDecrypt(),
                new SimpleRepository<Pago>(),
                new SimpleRepository<Itinerario>(),
                new SimpleRepository<Pais>(),
                new SimpleRepository<Asignatura>(),
                new SimpleRepository<AsignaturaExterna>(),
                new SimpleRepository<Estudio>(),
                new SimpleRepository<EstudioExterno>(),
                new SimpleRepository<DatosPersonales>(),
                }); }
        }

        //protected override IObjectPersistorInstaller Persistor {
        //    get { return new EntityPersistorInstaller(); }
        //}
		//For 'Code First' development replace Persistor property with:
        protected override IObjectPersistorInstaller Persistor
        {
            get
            {                
                return new EntityPersistorInstaller
                {
                    CodeFirst = true,
                    CodeFirstConfig = new[] {
                    new EntityPersistorInstaller.EntityCodeFirstConfig {AssemblyName = "RTC.Modelo", DataSource = @".\SqlExpress2005", DatabaseName = "RTC"}}
                };
            }
        }
        public static void Run() {            
            new RunWeb().Start();
        }
    }
}